﻿

class DefaultGetCell implements IGetCell {
    grid: IGrid;
    deadCell: DefaultCell;
    Init(grid: IGrid)
    {
        this.grid = grid; 
        this.deadCell = new DefaultCell();
        this.deadCell.InitCell(grid, CellState.Dead, -1, -1);
    }

    
    Execute( x: number, y: number)
    {
        //if (y < 0)
        //    y = this.grid.Height - 1;
        //if (y >= this.grid.Height)
        //    y = 0;

        //if (x < 0)
        //    x = this.grid.Width - 1;
        //if (x >= this.grid.Width)
        //    x = 0;

        if ((y < 0) || (y >= this.grid.Height) || (x < 0) || (x >= this.grid.Width))
            return this.deadCell;

        return this.grid.GetCellRaw(x, y);

        
    }


}